package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolFeedBackView;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolFeedBackModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolFeedBackModel;

/**
 * Created by tony on 2018/5/30.
 */

public class PatrolFeedBackPresenter {

    private IPatrolFeedBackView view;
    private IPatrolFeedBackModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolFeedBackPresenter(IPatrolFeedBackView view) {
        this.view = view;
        this.model = new PatrolFeedBackModel();
    }

    public void patrolFeedBack() {


        model.patrolFeedBack(view.getPatrolFeedbackBean(),
                new PatrolFeedBackModel.OnPatrolFeedBackListener() {
                    @Override
                    public void patrolFeedBackSuccessed() {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.ptrolFeedBackSuccessed();
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void patrolFeedBackFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.ptrolFeedBackFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
